#include <stdio.h>

int main(int argc, char *argv[]) {

    int n = 0, count = 0;
    scanf("%d", &n);
    
    for (size_t i = 1; i <= n; i++)
    {
        int g = 0, s = 0, b = 0, q = 0, w = 0;
        if(i%7==0){
            count++;
            continue;
        }
        if(i<100){
            g = i % 10;
            s = i / 10 % 10;
            if(g==7||s==7)
                count++;
        }else if(i>=100&&i<1000){
            g = i % 10;
            s = i / 10 % 10;
            b = i / 100 % 10;
            if(g==7||b==7||s==7)
                count++;
        }else if(i>=1000&&i<10000){
            g = i % 10;
            s = i / 10 % 10;
            b = i / 100 % 10;
            q = i / 1000 % 10;
            if(g==7||b==7||s==7||q==7)
                count++;
        }else{
            g = i % 10;
            s = i / 10 % 10;
            b = i / 100 % 10;
            q = i / 1000 % 10;
            w = i % 10000 % 10;
            if(g==7||b==7||s==7||q==7||w==7)
                count++;
        }
    }
    printf("%d", count);

    return 0;
}
